dynamic class D2.Vector{
	private var $mod:Number;
	private var $alpha:Number;
	
	public function get Mod():Number{
		return this.$mod;
	}
	public function set Mod(value:Number){
		this.$mod=value;
	}
	
	public function get Alpha():Number{
		return this.$alpha;
	}
	public function set Alpha(value:Number){
		this.$alpha=(Math.PI*2+value)%(2*Math.PI);
	}
	
	public function Vector(mod:Number,alpha:Number){
		if(mod==undefined){
			mod=0;
		}
		if(alpha==undefined){
			alpha=0;
		}
		this.$alpha=(Math.PI*2+alpha)%(2*Math.PI);
		this.$mod=mod;
	}
	
	public function toString(){
		return "mod:"+this.$mod+"  --  alpha:"+this.$alpha;
	}
	public function getMeasure(alpha:Number){
		if(alpha==((this.$alpha+Math.PI)%(Math.PI*2))){
			return [getAnti(),getAnti()];
		}
		alpha=(Math.PI*2+alpha)%(2*Math.PI);
		
		var a:Number=Math.cos(alpha-this.$alpha)*this.$mod;
		var b:Number=Math.cos(alpha-this.$alpha-Math.PI/2)*this.$mod;
		return [new Vector(a,alpha),new Vector(b,alpha-Math.PI/2)];
		
	}
	public function getAnti():Vector{
		return new Vector(-this.$mod,(this.$alpha+Math.PI)%(2*Math.PI));
	}
	public function add():Vector{
		
		var args:Array=arguments;
		if(args.length<=0){
			return null;
		}
		else if(args.length>1){
			if(args[0]!=undefined && args[1]!=undefined){
				var vt:Vector =new Vector(args[0],args[1]);
				return add(vt);
			}else{
				trace("add args error. -- "+arguments);
			}
			
		}
		
		else if(args.length==1){
			if(args[0].Mod!=undefined){
				var vt:Vector =Vector(args[0]);
				if(vt.Mod==0) return this;
				var a:Number=this.$mod;
				if(a==0) return vt;
				var b:Number=vt.Mod;
				var C:Number=Math.abs(this.$alpha-vt.Alpha);
				var c:Number=0;
				var alpha_a:Number=0;
				if(C>Math.PI){
					C=2*Math.PI-C;
				}else if (C>2*Math.PI){
					C=0;
				}
				if(C==0){
					c=a+b;
					alpha_a=0;
				}else{
					c=Math.sqrt(a*a+b*b-2*a*b*Math.cos(C));
					alpha_a=Math.acos((b*b+c*c-a*a)/(2*b*c));
				}
				var A:Number=(Math.max(this.$alpha,vt.$alpha))-alpha_a;
				
				//trace([a,b,c,C,alpha_a,A,(b*b+c*c-a*a)/(2*b*c)]);
				
				return new Vector(c,A);
			}else{
				trace("add args error 2. -- "+arguments);
			}
		}
		
	}
}